#!/bin/bash

dir="${1}"
shift 1

if [ -z "${dir}" ]
then
    1>&2 echo "usage:"
    1>&2 echo "  ${0} <directory> [<option>]"
    exit 1
fi

port="${1:-0}"
shift 1

host="${HOST:-0.0.0.0}"

# --samples_per_plugin=images=100 shows up to 100 images:
#
# https://github.com/tensorflow/tensorboard/issues/1012#issuecomment-397758274
#
images="${IMAGES:-100}"

echo "http://$(curl -fsSL api.ipify.org):${port}"
echo ""

set -x
exec tensorboard --host "${host}" --port "${port}" --logdir "$dir" --samples_per_plugin=images="${images}" "$@"
